package com.atwisdom.star.controller;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.thirdInterface.business.InterfaceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/interface")
public class InterfaceController {
    @Resource
    HttpServletRequest httpServletRequest;

    @Resource
    InterfaceService interfaceService;

    /**
     * 外部接口
     */
    @ApiOperation(value = "保存实例", notes = "外部接口")
    @PostMapping(value = "/saveEntity")
    @ResponseBody
    public ResultInfo<?> saveEntity(@RequestBody JSONObject param) {
        return interfaceService.addEntity(param,httpServletRequest);
    }

    /**
     * 外部接口
     */
    //@ApiOperation(value = "批量保存实例", notes = "批量外部接口")
    @PostMapping(value = "/saveEntityBatch")
    @ResponseBody
    public ResultInfo<?> saveEntityBatch(@RequestBody List<JSONObject> param) {
        return interfaceService.addBatchEntity(param);
    }

    /**
     * 外部接口
     */
    //@ApiOperation(value = "更新实例", notes = "更新接口")
    @PostMapping(value = "/updateEntity")
    @ResponseBody
    public ResultInfo<?> updateEntity(@RequestBody JSONObject param) {
        return interfaceService.updateEntity(param);
    }
}
